package com.panasonic.cn.cmsc;

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;
import java.sql.SQLException;
import com.fujitsu.fks.jaaf.core.*;

public class SQLMUSR99{
	private Hashtable paramsString     = new Hashtable();
	private Hashtable paramsBigDecimal = new Hashtable();
	private Hashtable paramsFree       = new Hashtable();
	private String lastSql_ = null;

	private String getString(String name){
		if(name==null) return "";
		String returnStr = (String)paramsString.get(name);
		if(returnStr==null) return "";
		return "'"+FrameworkCommon.stringReplaceSQuote(returnStr)+"'";
	}

	private String getBigDecimal(String name){
		if(name==null) return "";
		BigDecimal returnStr = (BigDecimal)paramsBigDecimal.get(name);
		if(returnStr==null) return "";
		return returnStr.toString();
	}

	private String getFree(String name){
		if(name==null) return "";
		String returnStr = (String)paramsFree.get(name);
		if(returnStr==null) return "";
		return returnStr;
	}

	public String getLastSql(){
		return lastSql_;
	}

	public int INSERT_USR01(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("            INSERT INTO");
		sql.append("	    USR");
		sql.append("	    (");
		sql.append("	    USER_ID,");
		sql.append("	    USER_NAME,");
		sql.append("	    PASSWORD,");
		sql.append("	    CTRL_DVSN_CD,");
		sql.append("	    AUTH_LEVEL,");
		sql.append("	    BSNS_TYP,");
		sql.append("	    MAIL_ADDRESS,");
		sql.append("	    MAIL_SIZE,");
		sql.append("	    RGS_DTTM,");
		sql.append("	    RGS_CHRG_CD,");
		sql.append("	    RGS_PGID,");
		sql.append("	    UPD_DTTM,");
		sql.append("	    UPD_CHRG_CD,");
		sql.append("	    UPD_PGID");
		sql.append("	    )");
		sql.append("	    VALUES");
		sql.append("	    (");
		sql.append("	    "+getString("USER_ID")+",");
		sql.append("	    "+getString("USER_NAME")+",");
		sql.append("	    "+getString("PASSWORD")+",");
		sql.append("	    "+getString("CTRL_DVSN_CD")+",");
		sql.append("	    "+getString("AUTH_LEVEL")+",");
		sql.append("	    "+getString("BSNS_TYP")+", ");
		sql.append("	    "+getString("MAIL_ADDRESS")+",");
		sql.append("	    "+getBigDecimal("MAIL_SIZE")+",");
		sql.append("	    TO_DATE("+getString("RGS_DTTM")+",'YYYYMMDD HH24:MI:SS'),");
		sql.append("	    "+getString("RGS_CHRG_CD")+",");
		sql.append("	    "+getString("RGS_PGID")+",");
		sql.append("	    TO_DATE("+getString("UPD_DTTM")+",'YYYYMMDD HH24:MI:SS'),");
		sql.append("	    "+getString("UPD_CHRG_CD")+",");
		sql.append("	    "+getString("UPD_PGID")+"");
		sql.append("	    )");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public int UPDATE_USR02(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("	    UPDATE");
		sql.append("	    USR");
		sql.append("	    SET");
		sql.append("	    USER_ID "+((getString("USER_ID").equals(""))?" is null ":"=")+getString("USER_ID")+",");
		sql.append("	    USER_NAME "+((getString("USER_NAME").equals(""))?" is null ":"=")+getString("USER_NAME")+",");
		sql.append("	    PASSWORD "+((getString("PASSWORD").equals(""))?" is null ":"=")+getString("PASSWORD")+",");
		sql.append("	    CTRL_DVSN_CD "+((getString("CTRL_DVSN_CD").equals(""))?" is null ":"=")+getString("CTRL_DVSN_CD")+",");
		sql.append("	    AUTH_LEVEL "+((getString("AUTH_LEVEL").equals(""))?" is null ":"=")+getString("AUTH_LEVEL")+",");
		sql.append("	    BSNS_TYP "+((getString("BSNS_TYP").equals(""))?" is null ":"=")+getString("BSNS_TYP")+",");
		sql.append("	    MAIL_ADDRESS "+((getString("MAIL_ADDRESS").equals(""))?" is null ":"=")+getString("MAIL_ADDRESS")+",");
		sql.append("	    MAIL_SIZE "+((getBigDecimal("MAIL_SIZE").equals(""))?" is null ":"=")+getBigDecimal("MAIL_SIZE")+",");
		sql.append("	    RGS_DTTM = TO_DATE("+getString("RGS_DTTM")+",'YYYYMMDD HH24:MI:SS'),");
		sql.append("	    RGS_CHRG_CD "+((getString("RGS_CHRG_CD").equals(""))?" is null ":"=")+getString("RGS_CHRG_CD")+",");
		sql.append("	    RGS_PGID "+((getString("RGS_PGID").equals(""))?" is null ":"=")+getString("RGS_PGID")+",");
		sql.append("	    UPD_DTTM = TO_DATE("+getString("UPD_DTTM")+",'YYYYMMDD HH24:MI:SS'),");
		sql.append("	    UPD_CHRG_CD "+((getString("UPD_CHRG_CD").equals(""))?" is null ":"=")+getString("UPD_CHRG_CD")+",");
		sql.append("	    UPD_PGID "+((getString("UPD_PGID").equals(""))?" is null ":"=")+getString("UPD_PGID")+"");
		sql.append("	    WHERE");
		sql.append("	    USER_ID "+((getString("USER_ID").equals(""))?" is null ":"=")+getString("USER_ID")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public int UPDATE_USR03(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("		UPDATE");
		sql.append("		USR");
		sql.append("		SET");
		sql.append("		APL_EDT "+((getString("APL_BDT").equals(""))?" is null ":"=")+getString("APL_BDT")+"");
		sql.append("		WHERE  ");
		sql.append("		USER_ID "+((getString("USER_ID").equals(""))?" is null ":"=")+getString("USER_ID")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public int UPDATE_USR04(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("		  UPDATE");
		sql.append("		  USR");
		sql.append("		  SET");
		sql.append("		  APL_BDT "+((getString("APL_BDT").equals(""))?" is null ":"=")+getString("APL_BDT")+"");
		sql.append("		  WHERE  ");
		sql.append("		  USER_ID "+((getString("USER_ID").equals(""))?" is null ":"=")+getString("USER_ID")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public int UPDATE_USR05(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("		UPDATE");
		sql.append("		USR ");
		sql.append("		SET");
		sql.append("		APL_EDT "+((getString("APL_EDT").equals(""))?" is null ":"=")+getString("APL_EDT")+"");
		sql.append("		WHERE  ");
		sql.append("		USER_ID "+((getString("USER_ID").equals(""))?" is null ":"=")+getString("USER_ID")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public int DELETE_USR06(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("		DELETE");
		sql.append("		FROM");
		sql.append("		USR");
		sql.append("		WHERE  ");
		sql.append("		USER_ID "+((getString("USER_ID").equals(""))?" is null ":"=")+getString("USER_ID")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public SelectResultRset SELECT_USR07(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("	   SELECT");
		sql.append("	   (");
		sql.append("	   USER_ID,");
		sql.append("	    USER_NAME,");
		sql.append("	    PASSWORD,");
		sql.append("	    CTRL_DVSN_CD,");
		sql.append("	    AUTH_LEVEL,");
		sql.append("	    BSNS_TYP,");
		sql.append("	    MAIL_ADDRESS,");
		sql.append("	    MAIL_SIZE,");
		sql.append("	    RGS_DTTM,");
		sql.append("	    RGS_CHRG_CD,");
		sql.append("	    RGS_PGID,");
		sql.append("	    UPD_DTTM,");
		sql.append("	    UPD_CHRG_CD,");
		sql.append("	    UPD_PGID");
		sql.append("	    )");
		sql.append("	    FROM");
		sql.append("	    USR");
		sql.append("	    WHERE");
		sql.append("	    USER_ID "+((getString("USER_ID").equals(""))?" is null ":"=")+getString("USER_ID")+"    		");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}


	public void setUSER_ID(String value){
		if(value==null) {
			paramsString.remove("USER_ID");
			return;
		}
		paramsString.put("USER_ID",value);
	}


	public void setUSER_NAME(String value){
		if(value==null) {
			paramsString.remove("USER_NAME");
			return;
		}
		paramsString.put("USER_NAME",value);
	}


	public void setPASSWORD(String value){
		if(value==null) {
			paramsString.remove("PASSWORD");
			return;
		}
		paramsString.put("PASSWORD",value);
	}


	public void setCTRL_DVSN_CD(String value){
		if(value==null) {
			paramsString.remove("CTRL_DVSN_CD");
			return;
		}
		paramsString.put("CTRL_DVSN_CD",value);
	}


	public void setAUTH_LEVEL(String value){
		if(value==null) {
			paramsString.remove("AUTH_LEVEL");
			return;
		}
		paramsString.put("AUTH_LEVEL",value);
	}


	public void setBSNS_TYP(String value){
		if(value==null) {
			paramsString.remove("BSNS_TYP");
			return;
		}
		paramsString.put("BSNS_TYP",value);
	}


	public void setMAIL_ADDRESS(String value){
		if(value==null) {
			paramsString.remove("MAIL_ADDRESS");
			return;
		}
		paramsString.put("MAIL_ADDRESS",value);
	}


	public void setRGS_DTTM(String value){
		if(value==null) {
			paramsString.remove("RGS_DTTM");
			return;
		}
		paramsString.put("RGS_DTTM",value);
	}


	public void setRGS_CHRG_CD(String value){
		if(value==null) {
			paramsString.remove("RGS_CHRG_CD");
			return;
		}
		paramsString.put("RGS_CHRG_CD",value);
	}


	public void setRGS_PGID(String value){
		if(value==null) {
			paramsString.remove("RGS_PGID");
			return;
		}
		paramsString.put("RGS_PGID",value);
	}


	public void setUPD_DTTM(String value){
		if(value==null) {
			paramsString.remove("UPD_DTTM");
			return;
		}
		paramsString.put("UPD_DTTM",value);
	}


	public void setUPD_CHRG_CD(String value){
		if(value==null) {
			paramsString.remove("UPD_CHRG_CD");
			return;
		}
		paramsString.put("UPD_CHRG_CD",value);
	}


	public void setUPD_PGID(String value){
		if(value==null) {
			paramsString.remove("UPD_PGID");
			return;
		}
		paramsString.put("UPD_PGID",value);
	}


	public void setAPL_BDT(String value){
		if(value==null) {
			paramsString.remove("APL_BDT");
			return;
		}
		paramsString.put("APL_BDT",value);
	}


	public void setAPL_EDT(String value){
		if(value==null) {
			paramsString.remove("APL_EDT");
			return;
		}
		paramsString.put("APL_EDT",value);
	}


	public void setMAIL_SIZE(BigDecimal value){
		if(value==null) {
			paramsBigDecimal.remove("MAIL_SIZE");
			return;
		}
		paramsBigDecimal.put("MAIL_SIZE",value);
	}


}
